import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '装置名',
    align: "center",
    dataIndex: 'deviceName_dictText'
  },
  {
    title: '区域名',
    align: "center",
    dataIndex: 'areaName'
  },
  {
    title: '区域编码',
    align: "center",
    dataIndex: 'areaCode'
  },
  {
    title: '是否受控区域',
    align: "center",
    dataIndex: 'isControl_dictText'
  },
  {
    title: '区域描述',
    align: "center",
    dataIndex: 'areaCommit'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '更新日期',
    align: "center",
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "装置名",
    field: 'deviceName',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "device,device_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "区域名",
    field: 'areaName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "区域编码",
    field: 'areaCode',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '装置名',
    field: 'deviceName',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "device,device_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入装置名!'},
             ];
    },
  },
  {
    label: '区域名',
    field: 'areaName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入区域名!'},
             ];
    },
  },
  {
    label: '区域编码',
    field: 'areaCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入区域编码!'},
              { pattern: '^.{1,30}$', message: '不符合校验规则!'},
             ];
    },
  },
  {
    label: '是否受控区域',
    field: 'isControl',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "is_or_not"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否受控区域!'},
             ];
    },
  },
  {
    label: '区域描述',
    field: 'areaCommit',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: false},
              { pattern: '^.{1,100}$', message: '不符合校验规则!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  deviceName: {title: '装置名',order: 0,view: 'list', type: 'string',dictTable: 'device', dictCode: 'id', dictText: 'device_name',},
  areaName: {title: '区域名',order: 1,view: 'text', type: 'string',},
  areaCode: {title: '区域编码',order: 2,view: 'text', type: 'string',},
  isControl: {title: '是否受控区域',order: 3,view: 'list', type: 'string',dictCode: 'is_or_not',},
  areaCommit: {title: '区域描述',order: 4,view: 'text', type: 'string',},
  updateBy: {title: '更新人',order: 5,view: 'text', type: 'string',},
  updateTime: {title: '更新日期',order: 6,view: 'datetime', type: 'string',},
};
